#include "Protocols/ShowableItem.h"

using std::endl;

void ShowableItem::show(std::ostream& os) const
{
	showProc(this,0,os);
}

void ShowableItem::showProc(const ShowableItem* root,int layer,std::ostream& os) const
{
	int i = 0;

	if (layer > 1) {
		while(i < (layer - 1)) {
			os << '\t';
			++ i;
		}
	}

	if (layer != 0) {
		os << qPrintable(root->getKey()) << " " << qPrintable(root->getValue()) << "  " << qPrintable(root->getRemark())
		   << '[' << root->getBeginIndex() << '-' << root->getEndIndex()  << ']' << endl;

	}

	for (int i = 0; i < root->childCount(); ++ i) {
		showProc(root->getChild(i),layer + 1,os);
	}

}